home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / screen / password.frm < prev    next >
Text File  |  1994-11-28  |  5KB  |  213 lines

  1. VERSION 2.00
  2. Begin Form frmPassword 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Change Password"
  5.    ClientHeight    =   2085
  6.    ClientLeft      =   2490
  7.    ClientTop       =   2790
  8.    ClientWidth     =   4695
  9.    Height          =   2490
  10.    Left            =   2430
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2085
  15.    ScaleWidth      =   4695
  16.    Top             =   2445
  17.    Width           =   4815
  18.    Begin CommandButton cmdCancel 
  19.       Cancel          =   -1  'True
  20.       Caption         =   "Cancel"
  21.       Height          =   375
  22.       Left            =   3360
  23.       TabIndex        =   7
  24.       Top             =   1560
  25.       Width           =   1215
  26.    End
  27.    Begin CommandButton cmdOK 
  28.       Caption         =   "OK"
  29.       Default         =   -1  'True
  30.       Height          =   375
  31.       Left            =   120
  32.       TabIndex        =   6
  33.       Top             =   1560
  34.       Width           =   1215
  35.    End
  36.    Begin TextBox txtRetype 
  37.       Enabled         =   0   'False
  38.       Height          =   315
  39.       Left            =   2160
  40.       MaxLength       =   20
  41.       PasswordChar    =   "*"
  42.       TabIndex        =   5
  43.       Top             =   1080
  44.       Width           =   2415
  45.    End
  46.    Begin TextBox txtNew 
  47.       Enabled         =   0   'False
  48.       Height          =   315
  49.       Left            =   2160
  50.       MaxLength       =   20
  51.       PasswordChar    =   "*"
  52.       TabIndex        =   4
  53.       Top             =   600
  54.       Width           =   2415
  55.    End
  56.    Begin TextBox txtOld 
  57.       Height          =   315
  58.       Left            =   2160
  59.       MaxLength       =   20
  60.       PasswordChar    =   "*"
  61.       TabIndex        =   3
  62.       Top             =   120
  63.       Width           =   2415
  64.    End
  65.    Begin Label lblRetype 
  66.       Caption         =   "Retype New Password:"
  67.       Enabled         =   0   'False
  68.       Height          =   195
  69.       Left            =   120
  70.       TabIndex        =   2
  71.       Top             =   1140
  72.       Width           =   1995
  73.    End
  74.    Begin Label lblNew 
  75.       Caption         =   "New Password"
  76.       Enabled         =   0   'False
  77.       Height          =   195
  78.       Left            =   120
  79.       TabIndex        =   1
  80.       Top             =   660
  81.       Width           =   1695
  82.    End
  83.    Begin Label lblOld 
  84.       Caption         =   "Old Password:"
  85.       Height          =   195
  86.       Left            =   120
  87.       TabIndex        =   0
  88.       Top             =   180
  89.       Width           =   1635
  90.    End
  91. End
  92. Option Explicit
  93.  
  94. Sub cmdCancel_Click ()
  95.     
  96.     Unload Me
  97.  
  98. End Sub
  99.  
  100. Sub cmdOK_Click ()
  101.     
  102. Dim putback As String
  103.     '
  104.     ' Validate the change of password
  105.     '
  106.     If Password <> CalcPassnum((txtOld.Text)) Then
  107.         MsgBox "The value for Old Password is not correct." & Chr$(13) & Chr$(13) & "Check your screen saver password, and then try again.", 16, "Change Password"
  108.         txtNew.Text = ""
  109.         txtRetype.Text = ""
  110.         txtOld.SetFocus
  111.         Exit Sub
  112.     End If
  113.     If txtNew.Text <> txtRetype.Text Then
  114.         MsgBox "The Values for New Password and Retype New" & Chr$(13) & "Password do not match." & Chr$(13) & Chr$(13) & "Try again.", 16, "Change Password"
  115.         txtNew.Text = ""
  116.         txtRetype.Text = ""
  117.         txtNew.SetFocus
  118.         Exit Sub
  119.     End If
  120.     '
  121.     ' Write the password to the ini file
  122.     '
  123.     Password = CalcPassnum((txtNew.Text))
  124.     If Password <> OldPassword Then
  125.         putback = Format$(Password)
  126.         Call PutIni(iniName, iniSection, "Password", putback)
  127.         OldPassword = Password
  128.     End If
  129.     Unload Me
  130.  
  131. End Sub
  132.  
  133. Sub Form_Load ()
  134.     
  135.     '
  136.     ' Enable the text boxes and lables as appropriate
  137.     '
  138.     If Password > 0 Then
  139.         txtOld.Enabled = True
  140.         lblOld.Enabled = True
  141.         txtNew.Enabled = False
  142.         lblNew.Enabled = False
  143.         txtRetype.Enabled = False
  144.         lblRetype.Enabled = False
  145.     Else
  146.         txtOld.Enabled = False
  147.         lblOld.Enabled = False
  148.         txtNew.Enabled = True
  149.         lblNew.Enabled = True
  150.         txtRetype.Enabled = True
  151.         lblRetype.Enabled = True
  152.     End If
  153.     
  154.     CentreForm Me
  155.  
  156. End Sub
  157.  
  158. Sub txtNew_GotFocus ()
  159.  
  160.     txtNew.SelStart = 0
  161.     txtNew.SelLength = Len(txtNew.Text)
  162.  
  163. End Sub
  164.  
  165. Sub txtNew_LostFocus ()
  166.     txtNew.Text = UCase$(txtNew.Text)
  167.  
  168. End Sub
  169.  
  170. Sub txtOld_Change ()
  171.     '
  172.     ' Enable the text boxes and lables as appropriate
  173.     '
  174.     If Len(txtOld) > 0 Then
  175.         txtNew.Enabled = True
  176.         lblNew.Enabled = True
  177.         txtRetype.Enabled = True
  178.         lblRetype.Enabled = True
  179.     Else
  180.         txtNew.Enabled = False
  181.         lblNew.Enabled = False
  182.         txtRetype.Enabled = False
  183.         lblRetype.Enabled = False
  184.  
  185.     End If
  186.  
  187. End Sub
  188.  
  189. Sub txtOld_GotFocus ()
  190.     
  191.     txtOld.SelStart = 0
  192.     txtOld.SelLength = Len(txtOld.Text)
  193.  
  194. End Sub
  195.  
  196. Sub txtOld_LostFocus ()
  197.     txtOld.Text = UCase$(txtOld.Text)
  198. End Sub
  199.  
  200. Sub txtRetype_GotFocus ()
  201.  
  202.     txtRetype.SelStart = 0
  203.     txtRetype.SelLength = Len(txtRetype.Text)
  204.  
  205. End Sub
  206.  
  207. Sub txtRetype_LostFocus ()
  208.     
  209.     txtRetype.Text = UCase$(txtRetype.Text)
  210.  
  211. End Sub
  212.  
  213.